package com.dxy.tank;

import java.io.IOException;
import java.util.Properties;

public class PropertyMgr {
    private PropertyMgr() {
    }

    private static Properties props = new Properties();
    private static PropertyMgr instance = null;

    public PropertyMgr getInstance() {
        if (instance == null) {
            instance = new PropertyMgr();
        }
        return instance;
    }

    static {
        try {
            props.load(PropertyMgr.class.getClassLoader().getResourceAsStream("config"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Object get(String key) {
        if (props == null) return null;
        return props.get(key);
    }

	public static int getInt(String key) {
		if (props == null) return 0;
		return Integer.parseInt((String) props.get(key));
	}

    public static String getString(String key) {
        if (props == null) return "";
        return (String) props.get(key);
    }

    public static void main(String[] args) {
        System.out.println(PropertyMgr.get("initTankCount"));

    }
}
